home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / include / scribus-ng / util.h < prev    next >
Encoding:
C/C++ Source or Header  |  2009-01-26  |  6.1 KB  |  150 lines

  1. /*
  2. For general Scribus (>=1.3.2) copyright and licensing information please refer
  3. to the COPYING file provided with the program. Following this notice may exist
  4. a copyright and/or license notice that predates the release of Scribus 1.3.2
  5. for which a new license (GPL+exception) is in place.
  6. */
  7. #ifndef _UTIL_H
  8. #define _UTIL_H
  9.  
  10. #include <vector>
  11.  
  12. #include <QByteArray>
  13. #include <QColor>
  14. #include <QComboBox>
  15. #include <QDataStream>
  16. #include <QDir>
  17. #include <QList>
  18. #include <QPainterPath>
  19. #include <QPixmap>
  20. #include <QString>
  21. #include <QStringList>
  22. #include <QVector>
  23.  
  24. #include "pagestructs.h"
  25. // #include "style.h"
  26. // #include "styles/charstyle.h"
  27. // #include "styles/paragraphstyle.h"
  28. #include "scribusapi.h"
  29.  
  30. class  QDomElement;
  31. class  QWidget;
  32. class  PageItem;
  33. class  ParagraphStyle;
  34. class  ScribusDoc;
  35. class  ScribusView;
  36. class  ScStreamFilter;
  37. struct CopyPasteBuffer;
  38.  
  39. // class Foi;
  40.  
  41. /*! \brief Compare double values by pre-multiplying by 10000 and converting to long if possible.
  42. If premultiplication does not allow to store result in a long value, perform a standard comparison.
  43. */
  44. bool SCRIBUS_API compareDouble(double a, double b);
  45.  
  46. /*! \brief Returns a sorted list of QStrings - sorted by locale specific rules!
  47. Uses compareQStrings() as rule. There is STL used!
  48. \author Petr Vanek
  49. \param aList unsorted string list
  50. \retval QStringList sorted string list
  51.  */
  52. QStringList SCRIBUS_API sortQStringList(QStringList aList);
  53. void SCRIBUS_API ReOrderText(ScribusDoc *currentDoc, ScribusView *view);
  54. void SCRIBUS_API WordAndPara(PageItem *currItem, int *w, int *p, int *c, int *wN, int *pN, int *cN);
  55. bool SCRIBUS_API overwrite(QWidget *parent, QString filename);
  56. QByteArray SCRIBUS_API ComputeMD5Sum(QByteArray *in);
  57. QString SCRIBUS_API Path2Relative(QString Path, const QString& baseDir = QDir::currentPath());
  58. QString SCRIBUS_API Relative2Path(QString File, const QString& baseDir = QDir::currentPath());
  59. char SCRIBUS_API *toAscii85( quint32 value, bool& allZero );
  60. char SCRIBUS_API *toHex( uchar u );
  61. QString SCRIBUS_API String2Hex(QString *in, bool lang = true);
  62. QString SCRIBUS_API CompressStr(QString *in);
  63. QByteArray SCRIBUS_API CompressArray(const QByteArray& in);
  64. //! \brief WARNING: loadText is INCORRECT - use loadRawText instead!
  65. bool SCRIBUS_API loadText(QString nam, QString *Buffer);
  66. /*! \brief Replacement version of loadText that returns a QCString as an out parameter.
  67. The QCString is filled with the contents of the specified file. The return
  68. byte string is of unknown encoding; the caller must handle encoding issues.
  69. There is no need to preallocate the buffer, and the new data replaces any
  70. old contents. */
  71. bool SCRIBUS_API loadRawText(const QString & filename, QByteArray & buf);
  72. bool SCRIBUS_API loadRawBytes(const QString & filename, QByteArray & buf);
  73. QString SCRIBUS_API GetAttr(QDomElement *el, QString at, QString def="0");
  74. /**
  75. * @brief Synchronously execute a new process, optionally saving its output
  76.    *
  77.    * Create a new process via QProcess and wait until finished.  Return the
  78.    * process exit code. Exit code 1 is returned if the process could not be
  79.    * started or terminated abnormally.
  80.    *
  81.    * Note that the argument list is handled exactly as documented by QProcess.
  82.    * In particular, no shell metacharacter expansion is performed (so you can't
  83.    * use $HOME for example, and no quoting is required or appropriate), and each
  84.    * list entry is one argument.
  85.    *
  86.    * If output file paths are provided, any existing file will be truncated and
  87.    * overwritten.
  88.    *
  89.     \param exename name of the executable
  90.    * @param args Arguments, as per QProcess documentation.
  91.    * @param fileStdErr Path to save error output to, or "" to discard.
  92.    * @param fileStdOut Path to save normal output to, or "" to discard
  93.     \param cancel a reference(!) to bool - flag used to kill the process
  94.    * @return Program exit code, or 1 on failure.
  95.    *
  96. */
  97. int SCRIBUS_API System(const QString exename, const QStringList & args,
  98.                        const QString fileStdErr = "", const QString fileStdOut = "",
  99.                        bool* cancel = NULL);
  100.  
  101. /*!
  102.  \fn QString checkFileExtension(const QString &currName, const QString &extension)
  103.  \author Craig Bradney
  104.  \brief A quick function to make sure a filename has the correct extension and add it if not
  105.  \param currName Current filename
  106.  \param extension File extension to ensure exists
  107.  */
  108. QString SCRIBUS_API checkFileExtension(const QString & currName, const QString & extension);
  109. /*! \brief On Windows, return short path name, else return longPath
  110. \param longPath the whole path
  111. \retval QString transformed path
  112. */
  113. QString SCRIBUS_API getShortPathName(const QString & longPath);
  114. /*! \brief On Windows, return long path name, else return shortPath
  115. \param shortPath the short path
  116. \retval QString transformed path
  117. */
  118. QString SCRIBUS_API getLongPathName(const QString & shortPath);
  119. /*! \brief Creates a common name for page exports (SVG, bitmap, EPS).
  120.    Output format is: documentname-page01.extension
  121.    \param currDoc a reference to the ScribusDoc document
  122.    \param pageNo number of the exported page (begins from 1)
  123.    \param extension "svg" or e.g. "png" etc.
  124.    \retval QString standardized filename
  125.    \author Petr Vanek
  126.  */
  127. QString SCRIBUS_API getFileNameByPage(ScribusDoc* currDoc, uint pageNo, QString extension);
  128. void SCRIBUS_API sDebug(QString message);
  129. const QString SCRIBUS_API getStringFromSequence(DocumentSectionType type, uint position);
  130. const QString SCRIBUS_API arabicToRoman(uint i);
  131. const QString SCRIBUS_API numberToLetterSequence(uint i);
  132. void SCRIBUS_API parsePagesString(QString pages, std::vector<int>* pageNs, int sourcePageCount);
  133.  
  134. /*! \brief performance measurements.
  135. It prints given message with it current timestamp.
  136. Useful for duration holes finding.
  137. \author Petr Vanek */
  138. void tDebug(QString message);
  139.  
  140. QString SCRIBUS_API readLinefromDataStream(QDataStream &s);
  141. void SCRIBUS_API setCurrentComboItem(QComboBox *box, QString text);
  142.  
  143. QString SCRIBUS_API getDashString(int dashtype, double linewidth);
  144. void    SCRIBUS_API getDashArray(int dashtype, double linewidth, QVector<double> &m_array);
  145. void    SCRIBUS_API getDashArray(int dashtype, double linewidth, QVector<float> &m_array);
  146.  
  147. void SCRIBUS_API printBacktrace(int nFrames);
  148.  
  149. #endif
  150.